package com.example.yt_app.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
import android.text.TextPaint;
import android.text.style.ClickableSpan;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.example.yt_app.R;
import com.example.yt_app.Urils.ClickableMovementMethod;
import com.example.yt_app.Urils.Json;
import com.example.yt_app.Urils.SB_Parameter;
import com.example.yt_app.Urils.SpannableStringUtils;
import com.example.yt_app.Urils.State;
import com.example.yt_app.Urils.Utils;
import com.example.yt_app.bean.HistoricalData.Datapoints;
import com.example.yt_app.bean.HistoricalData.Datastreams;
import com.example.yt_app.bean.HistoricalData.HistoricalJsonRootBean;
import com.example.yt_app.bean.Status;
import com.example.yt_app.data.DataServer;

import org.jetbrains.annotations.NotNull;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

/**
 *
 * @author dell
 * @date 2021/8/2
 */

@SuppressWarnings("ALL")
public class HistortyADapter extends BaseQuickAdapter<Status, BaseViewHolder> {
    ArrayList<Map<String, Object>> list;
    public HistortyADapter(ArrayList<Map<String, Object>> list) {

        super(R.layout.history_data_list, DataServer.getSampleData(SB_Parameter.HISTORYLIST));
        this.list = list;
    }

    @SuppressLint("ResourceType")
    @Override
    protected void convert(@NonNull BaseViewHolder helper, Status item) {
        int i = Integer.parseInt(list.get(helper.getLayoutPosition()).get("Value").toString());
        if (i == 0){
            helper.setText(R.id.tweetDate, "设备已开启");
        }else {
            helper.setText(R.id.tweetDate, "设备已关闭");
        }

        helper.setText(R.id.tweetName, "Value:"+ list.get(helper.getLayoutPosition()).get("Value").toString());
        helper.setText(R.id.tweetText, "Date:"+list.get(helper.getLayoutPosition()).get("Time").toString());

    }

    private ClickableSpan clickableSpan = new ClickableSpan() {
        @Override
        public void onClick(@NonNull View widget) {
        }

        @Override
        public void updateDrawState(TextPaint ds) {
            ds.setColor(getContext().getResources().getColor(R.color.clickspan_color));
            ds.setUnderlineText(true);
        }
    };
}